package com.neuedu.javase.api;

import java.util.Random;

/**
 * @auth 金山老师
 * title:   书籍代码
 * creatime: 2022-09-29 10:26
 * 描述 : 数学运算
 */
public class MyMath {

    public static void main(String[] args) {
        System.out.println("Math.PI = " + Math.PI);
        System.out.println("Math.E = " + Math.E);

        //三角函数
        System.out.println("Math.sin(10) = " + Math.sin(10));
        System.out.println("Math.cos(10) = " + Math.cos(10));
        System.out.println("Math.tan(10) = " + Math.tan(10));

        System.out.println("Math.abs(10) = " + Math.abs(10));
        System.out.println("Math.abs(-10) = " + Math.abs(-10));

        System.out.println("Math.sqrt(25) = " + Math.sqrt(25));


        System.out.println("Math.floor(3.3) = " + Math.floor(3.3));
        System.out.println("Math.floor(3.4) = " + Math.floor(3.4));
        System.out.println("Math.floor(3.5) = " + Math.floor(3.5));
        System.out.println("Math.floor(3.6) = " + Math.floor(3.6));
        System.out.println("Math.floor(3.7) = " + Math.floor(3.7));
        System.out.println("Math.floor(3.8) = " + Math.floor(3.8));



        System.out.println("Math.ceil(3.3) = " + Math.ceil(3.3));
        System.out.println("Math.ceil(3.4) = " + Math.ceil(3.4));
        System.out.println("Math.ceil(3.5) = " + Math.ceil(3.5));
        System.out.println("Math.ceil(3.6) = " + Math.ceil(3.6));
        System.out.println("Math.ceil(3.7) = " + Math.ceil(3.7));
        System.out.println("Math.ceil(3.8) = " + Math.ceil(3.8));


        System.out.println("Math.min(10,29) = " + Math.min(10, 29));
        System.out.println("Math.max(10,29) = " + Math.max(10, 29));

        System.out.println("Math.round(15.4) = " + Math.round(15.4));
        System.out.println("Math.round(15.5) = " + Math.round(15.5));
        System.out.println("Math.round(15.6) = " + Math.round(15.6));
        System.out.println("Math.round(15.7) = " + Math.round(15.7));
        System.out.println("Math.round(15.8) = " + Math.round(15.8));

        double d1 = 15.6;
        int int1 = (int) d1;

        System.out.println("Math.random() = " + Math.random());
        System.out.println("Math.random() = " + Math.random());
        System.out.println("Math.random() = " + Math.random());
        System.out.println("Math.random() = " + Math.random());
        System.out.println("Math.random() = " + Math.random());
        System.out.println("Math.random() = " + Math.random());
        System.out.println("Math.random() = " + Math.random());

        
        //随机数
        Random rnd = new Random();

        //随机整数
        System.out.println("========//随机整数=============");
        System.out.println("rnd.nextInt() = " + rnd.nextInt());
        System.out.println("rnd.nextInt() = " + rnd.nextInt());
        System.out.println("rnd.nextInt() = " + rnd.nextInt());
        System.out.println("rnd.nextInt() = " + rnd.nextInt());


        //随机浮点数
        System.out.println("========//随机浮点数=============");
        System.out.println("rnd.nextDouble() = " + rnd.nextDouble());
        System.out.println("rnd.nextDouble() = " + rnd.nextDouble());
        System.out.println("rnd.nextDouble() = " + rnd.nextDouble());
        System.out.println("rnd.nextDouble() = " + rnd.nextDouble());


//        [0-100]
        for (int i = 0; i < 100; i++) {
            System.out.println("rnd.nextInt(100) = " + (rnd.nextInt(100)+1));
        }



    }
}
